package fr.umlv.ig.listenerFactory;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;

import fr.umlv.ig.extraWindows.ConfigurationWindow;
import fr.umlv.ig.model.MetroModelImpl;

public class ApplicationListenerFactory {

	private static ConfigurationWindow cw;

	/**
	 * ActionListener which is showing a {@link ConfigurationWindow} to configure lines
	 */
	public static ActionListener toolWindow(final JFrame frame, final MetroModelImpl metroModel) {
		return new ActionListener() {

			@Override

			public void actionPerformed(ActionEvent e) {
				if(cw == null) {
					cw = new ConfigurationWindow(frame, "Line configuration", metroModel);
				}
				cw.start();
			}
		};
	}
	
	public static void setCw(ConfigurationWindow cw) {
		ApplicationListenerFactory.cw = cw;
	}
	
	public static ConfigurationWindow getCw() {
		return cw;
	}
}
